package ar.edu.itba.it.cg.grupo01.impl.color;

import java.awt.Color;

import javax.vecmath.Point3d;

import ar.edu.itba.it.cg.grupo01.api.Intersection;
import ar.edu.itba.it.cg.grupo01.api.color.ColorVariation;
import ar.edu.itba.it.cg.grupo01.api.shape.Shape;
import ar.edu.itba.it.cg.grupo01.impl.Camera;

public abstract class AbstractVariation implements ColorVariation {

	@Override
	public Color apply(Camera camera, Shape shape,
			Intersection<? extends Shape> intersection) {

		Point3d closest = intersection.closestTo(camera.getOrigin());

		Color shapeColor = shape.getColor();
		if (closest == null) {
			return shapeColor;
		}

		return apply(shapeColor, camera, closest);
	}

	protected abstract Color apply(Color shapeColor, Camera camera, Point3d closest);


	
	
}
